<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Order Confirmation</title>
</head>
<body>
<div id="BackLink">
    <a th:href="@{/mainForm}">Return to Main Menu</a>
</div>

<div id="Catalog">
    <p>Thank you, your order has been submitted.</p>

    <table>
        <tr>
            <th align="center" colspan="2">
                Order #<span th:text="${session.order.orderid}"></span>
                <span th:text="${#dates.format(session.order.orderdate, 'yyyy/MM/dd HH:mm:ss')}"></span>
            </th>
        </tr>
        <tr>
            <th colspan="2">Payment Details</th>
        </tr>
        <tr>
            <td>Card Type:</td>
            <td th:text="${session.order.cardtype}"></td>
        </tr>
        <tr>
            <td>Card Number:</td>
            <td>
                <span th:text="${session.order.creditcard}"></span> * Fake number!
            </td>
        </tr>
        <tr>
            <td>Expiry Date (MM/YYYY):</td>
            <td th:text="${session.order.exprdate}"></td>
        </tr>
        <tr>
            <th colspan="2">Billing Address</th>
        </tr>
        <tr>
            <td>First name:</td>
            <td th:text="${session.order.billtofirstname}"></td>
        </tr>
        <tr>
            <td>Last name:</td>
            <td th:text="${session.order.billtolastname}"></td>
        </tr>
        <tr>
            <td>Address 1:</td>
            <td th:text="${session.order.billaddr1}"></td>
        </tr>
        <tr>
            <td>Address 2:</td>
            <td th:text="${session.order.billaddr2}"></td>
        </tr>
        <tr>
            <td>City:</td>
            <td th:text="${session.order.billcity}"></td>
        </tr>
        <tr>
            <td>State:</td>
            <td th:text="${session.order.billstate}"></td>
        </tr>
        <tr>
            <td>Zip:</td>
            <td th:text="${session.order.billzip}"></td>
        </tr>
        <tr>
            <td>Country:</td>
            <td th:text="${session.order.billcountry}"></td>
        </tr>
        <tr>
            <th colspan="2">Shipping Address</th>
        </tr>
        <tr>
            <td>First name:</td>
            <td th:text="${session.order.shiptofirstname}"></td>
        </tr>
        <tr>
            <td>Last name:</td>
            <td th:text="${session.order.shiptolastname}"></td>
        </tr>
        <tr>
            <td>Address 1:</td>
            <td th:text="${session.order.shipaddr1}"></td>
        </tr>
        <tr>
            <td>Address 2:</td>
            <td th:text="${session.order.shipaddr2}"></td>
        </tr>
        <tr>
            <td>City:</td>
            <td th:text="${session.order.shipcity}"></td>
        </tr>
        <tr>
            <td>State:</td>
            <td th:text="${session.order.shipstate}"></td>
        </tr>
        <tr>
            <td>Zip:</td>
            <td th:text="${session.order.shipzip}"></td>
        </tr>
        <tr>
            <td>Country:</td>
            <td th:text="${session.order.shipcountry}"></td>
        </tr>
        <tr>
            <td>Courier:</td>
            <td th:text="${session.order.courier}"></td>
        </tr>
        <tr>
            <td colspan="2">
                Status: <span th:text="${session.order.status}"></span>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <table>
                    <tr>
                        <th>Item ID</th>
                        <th>Description</th>
                        <th>Quantity</th>
                        <th>Price</th>
                        <th>Total Cost</th>
                    </tr>
                    <tr th:each="lineItem : ${session.order.lineItems}">
                        <td>
                            <a th:href="@{/itemForm(itemId=${lineItem.item.itemid})}"
                               th:text="${lineItem.item.itemid}"></a>
                        </td>
                        <td>
                                <span th:if="${lineItem.item != null}"
                                      th:text="${lineItem.item.attr1 + ' ' +
                                               lineItem.item.attr2 + ' ' +
                                               lineItem.item.attr3 + ' ' +
                                               lineItem.item.attr4 + ' ' +
                                               lineItem.item.attr5 + ' ' +
                                               lineItem.item.product.name}"></span>
                            <i th:unless="${lineItem.item != null}">{description unavailable}</i>
                        </td>
                        <td th:text="${lineItem.quantity}"></td>
                        <td th:text="${#numbers.formatCurrency(lineItem.unitprice)}"></td>
                        <td th:text="${#numbers.formatCurrency(lineItem.total)}"></td>
                    </tr>
                    <tr>
                        <th colspan="5">
                            Total: <span th:text="${#numbers.formatCurrency(session.order.totalprice)}"></span>
                        </th>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
</body>
</html>